package iterator.service.impl;

import iterator.service.Container;
import iterator.service.Iterator;

public class NameRepository implements Container {
    public String[] names = {"robert","john"};
    @Override
    public Iterator getIterator() {
        return new NameIterator();
    }
    public class NameIterator implements Iterator{
        int index ;
        @Override
        public boolean hasNext() {
            if (index<names.length){
                return true;
            }
            return false;
        }

        @Override
        public Object next() {
            if (this.hasNext()){
                return names[index++];
            }
            return null;
        }
    }

}
